#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
using namespace std;

void shellsort(vector<int>& v,const int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap /= 2;
		for (int i = 0; i < n - gap; i++)
		{
			int end = i;
			int tmp = v[i + gap];
			while (end >= 0)
			{
				if (tmp > v[end])
				{
					v[end + gap] = v[end];
					end -= gap;
				}
				else
					break;
			}
			v[end + gap] = tmp;
		}
		for (const auto e : v)
		{
			cout << e;
			if (e != v[n - 1])
			{
				cout << ' ';
			}
		}
		cout << endl;
	}
}

void test1()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<int> v(n, 0);
		for (auto& e : v)
		{
			cin >> e;
		}
		shellsort(v, n);
		if (t)
		{
			cout << endl;
		}
	}

}

int main()
{
	test1();
	return 0;
}
